package com.spmanage.thread;

import java.util.Date;
import java.util.List;



public class StatThread extends Thread {

	
	
	public static long SLEEP_TIME = 1000*60;
	
	private boolean started = true;
	
	public boolean isStarted() {
		return started;
	}

	public void setStarted(boolean started) {
		this.started = started;
	}

	@Override
	public void run() {
		try {
			Thread.sleep(5000);
		} catch (InterruptedException e) {
			e.printStackTrace();
			return;
		}
		
		while(started){
			try {
				Thread.sleep(SLEEP_TIME);
			} catch (InterruptedException e) {
				return;
			}
			
			try{
				if(started){
					boolean flag = false;
					Date date = new Date();
					if(date.getHours()==6) {
						System.out.println("start task..");
						try {
							task();
						} catch (Exception e) {
							e.printStackTrace();
							try {
								Thread.sleep(60*1000*60);
							} catch (Exception e1) {
								e1.printStackTrace();
								return;
							} finally {

							}
							continue;
						} finally {

						}
						
						flag = true;
					} else {
						flag = false;
					}
				}
			}catch(Exception e){
				e.printStackTrace();
			}
		}
	}

	public static void task(){
		
	}
	
}
